package weifei.live.simulation.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import weifei.live.simulation.entity.Avatar;
import weifei.web.Result;

@RestController
@RequestMapping("/avatar")
public class AvatarController
{
    @Autowired
    private Avatar dao_avatar;


    @GetMapping("/getAvatarByID")
    @PostMapping("/getAvatarByID")
    public Result getAvatarByID(@RequestParam("id") Integer avatarId)
    {
        QueryWrapper<Avatar> qw_avatar = new QueryWrapper<>();
        qw_avatar.eq(Avatar.Column.ID.getName(), avatarId);
        var avatar = this.dao_avatar.selectOne(qw_avatar);
        if (avatar == null)
            return Result.failed("头像不存在");
        return Result.success("获取成功", avatar);
    }

    @GetMapping("/getAvatarContentByID")
    @PostMapping("/getAvatarContentByID")
    public Result getAvatarContentByID(@RequestParam("id") Integer avatarId)
    {
        QueryWrapper<Avatar> qw_avatar = new QueryWrapper<>();
        qw_avatar.eq(Avatar.Column.ID.getName(), avatarId);
        var avatar = this.dao_avatar.selectOne(qw_avatar);
        if (avatar == null)
            return Result.failed("头像不存在");
        return Result.success("获取成功", avatar.getContent());
    }
}


